<script setup lang="ts">
import { onMounted, ref } from "vue";

// 声明 props 类型
export interface variableFormByDeviceProps {
  formInline: {
    groupName: string;
    decimalPlaces: number;
    triggeringEvent: string;
  };
}

const props = withDefaults(defineProps<variableFormByDeviceProps>(), {
  formInline: () => ({
    groupName: "",
    decimalPlaces: 0,
    triggeringEvent: ""
  })
});

const newFormInline = ref(props.formInline);
onMounted(() => {
  // newFormInline.value.groupName = "";
  newFormInline.value.triggeringEvent = "Triggering";
  newFormInline.value.decimalPlaces = 2;
});
</script>

<template>
  <el-form :model="newFormInline" class="add_form">
    <el-form-item label="组名" prop="groupName">
      <el-input
        v-model="newFormInline.groupName"
        class="!w-[220px]"
        placeholder="请输入组名"
      />
    </el-form-item>
    <el-form-item label="小数位" prop="decimalPlaces">
      <el-input
        v-model="newFormInline.decimalPlaces"
        class="!w-[220px]"
        placeholder="请输入小数位"
      />
    </el-form-item>
    <el-form-item label="触发事件" prop="triggeringEvent">
      <el-input
        v-model="newFormInline.triggeringEvent"
        class="!w-[220px]"
        placeholder="请输入触发事件"
        type="textarea"
      />
    </el-form-item>
  </el-form>
</template>
<style lang="scss" scoped>
.add_form :deep(.el-form-item__label) {
  width: 130px !important;
}
</style>
